package com.hbnu.pojo;

import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserMapper {
    //1.添加用户
    @Insert("insert into tb_user values(#{id},#{username},#{address})")
    int addUser(User user);
    //2.删除用户
    @Delete("delete from tb_user where id=#{id}")
    int deleteUser(int id);
    //3.修改用户
    @Update("update tb_user set username=#{username},address=#{address} where id=#{id}")
    int updateUser(User user);
    //4.查询用户
    @Select("select * from tb_user where id=#{id}")
    User findUserById(int id);
    //5.查询所有用户
    @Select("select * from tb_user")
    List<User> findAllUser();
    //6.根据用户名查询用户
    @Select("select * from tb_user where username=#{username}")
    User findUserByName(String username);
    // 使用@Param注解
    @Update("update tb_user set address=#{address} where id=#{id}")
    int updateUserAddress(@Param("id") int id, @Param("address") String address);

    @Select("select * from tb_user where ${column}=#{value}")
    List<User> findUserByColumn(@Param("column") String column, @Param("value") String value);

    @Insert("insert into tb_user values(#{username},#{address})")
    int InsertUser1(User user);
}
